import { serialize, parse, type SerializeOptions, type ParseOptions } from 'cookie'
export default class Cookies {
    constructor(public data: string[] = []) {
    }
    *[Symbol.iterator]() {
        for (const item of this.data) {
            yield parse(item) as SerializeOptions & Record<string, string>
        }
    }
    get(name: string) {
        for (const cookie of this) {
            if (cookie[name] !== undefined) return cookie[name]
        }
    }
    set(name: string, value: string, options?: SerializeOptions) {
        this.data = [serialize(name, value, options)]
    }
    add(name: string, value: string, options?: SerializeOptions) {
        this.data.push(serialize(name, value, options))
    }
}